package com.example.english.mapper;

import com.example.english.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    /**
     *   查询所有学生四级成绩
     */
    @Select("select * from students")
    List<Student> list();


    /**
     *   添加学生
     */
    @Insert("insert into students(Serial_number,Student_id,Name,Gender,Age,Phone_number,Grades)" +
            "values(#{SerialNumber},#{StudentId},#{Name},#{Gender},#{Age},#{PhoneNumber},#{Grades})")
    void add(Student student);


    /**
     *   删除学生
     */
    @Delete("delete from students where Serial_number = #{id}")
    void delete(Long id);


    /**
     *   修改学生
     */
    @Update("update students set " +
            "Student_id = #{StudentId}, " +
            "Name = #{Name}, " +
            "Gender = #{Gender}, " +
            "Age = #{Age}, " +
            "Phone_number = #{PhoneNumber}, " +
            "Grades = #{Grades} " +
            "where Serial_number = #{SerialNumber}")
    void update(Student student);


    @Select("select * from students where Serial_number  like concat('%',#{inputKeyword},'%')")
    List<Student> BySerialNumber(Long inputKeyword);

    @Select("select * from students where Student_id  like concat('%',#{inputKeyword},'%')")
    List<Student> ByStudentId(Integer inputKeyword);

    @Select("select * from students where Name  like concat('%',#{inputKeyword},'%')")
    List<Student> ByName(String inputKeyword);

    @Select("select * from students where Gender  like concat('%',#{inputKeyword},'%')")
    List<Student> ByGender(String inputKeyword);

    @Select("select * from students where Age  like concat('%',#{inputKeyword},'%')")
    List<Student> ByAge(Integer inputKeyword);

    @Select("select * from students where Phone_number  like concat('%',#{inputKeyword},'%')")
    List<Student> ByPhoneNumber(Long inputKeyword);

    @Select("select * from students where Grades  like concat('%',#{inputKeyword},'%')")
    List<Student> ByGrades(Integer inputKeyword);
}
